<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <script type="text/javascript" src="./code/lib/vue-2.4.0.js"></script>
    <style type="text/css">
        li{
            line-height: 30px;
            border: 1px dashed #000;
            margin: 5px;
            font-size:12px;
            width: 100%;
        }
        li:hover{
            background-color: #0094ff;
            transition: all 0.6s ease;
        }
        .v-enter,
        .v-leave-to{
            opacity: 0;
            transform: translateY(80px);
        }

        .v-enter-active,
        .v-leave-active{
            transition: all 0.8s ease;
        }
        .v-move{
            transition: all 0.8s ease;
        }
        .v-leave-active{
            position: absolute;
        }
    </style>
</head>
<body>

    <div id="app">
        <label>
            Id:
            <input type="text" v-model="id" />
        </label>

        <label>
            Name:
            <input type="text" v-model="name" />
        </label>

        <input type="button" value="添加" @click="add" />
        <!-- <ul> -->
            <transition-group appear tag="ul">
                <li v-for="(item, i) in list" :key="item.id" @click="del(i)" >
                    {{ item.id }} --- {{ item.name }}
                </li>
            </transition-group>
        <!-- </ul> -->
    </div>

    <script type="text/javascript">
        // 创建 Vue实例，得到 ViewModel
        var vm = new Vue({
            el: '#app',

            data: {
                id: '',
                name: '',
                list:[
                    { id: 1, name: '赵高1' },
                    { id: 2, name: '赵高2' },
                    { id: 3, name: '赵高3' },
                    { id: 4, name: '赵高4' }
                ]
            },
            methods: {
                add(){
                    this.list.push({ id: this.id, name: this.name });
                    this.id = this.name ='';
                },
                del(i){
                    this.list.splice(i, 1);
                }
            }
        });
    </script>
</body>
</html>